/**
 * 
 */
package JUnitTests;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import Framework.*;
/**
 * @author Pierre-Olivier
 *
 */
public class TestDice {

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception 
	{
		testRollAndGetResult();
		testSetGetFaces();
		testIntensiveRoll();
	}

	/**
	 * Test method for {@link Framework.Dice#Dice(java.lang.Object)}.
	 */
	@Test
	public final void testIntensiveRoll() 
	{
		Dice d = new Dice(5000);
		
		for (int i = 0; i < 10000; ++i)
		{
			d.roll();
			
			if (!(d.getResult() >= 1 && d.getResult() <= 5000))
				fail("Roll or GetResult failed");			
		}
	}

	/**
	 * Test method for {@link Framework.Dice#Dice(java.lang.Object)}.
	 */
	@Test
	public final void testRollAndGetResult() 
	{
		Dice d = new Dice();
		d.roll();
		
		if (d.getResult() <= 0)
			fail("Roll or GetResult failed");
	}


	/**
	 * Test method for {@link Framework.Dice#Dice(java.lang.Object)}.
	 */
	@Test
	public final void testSetGetFaces()
	{
		Dice d = new Dice();
		
		d.SetFaces(2);
		if (d.getFaces() != 2)
			fail("Get or Set faces failed"); 
		
		d.SetFaces(-1);
		if (d.getFaces() == -1)
			fail("Get or Set faces failed");
		
		d.SetFaces(0);
		if (d.getFaces() == 0)
			fail("Get or Set faces failed"); 
			
	}

}
